package com.chushouya.controller.manager.api;

import com.chushouya.common.annotations.AuthSkip;
import com.chushouya.common.constant.ServiceType;
import com.chushouya.manager.dto.admin.home.HomeDataDTO;
import com.chushouya.manager.dto.api.home.HomeDataQueryDTO;
import com.chushouya.manager.service.api.HomeApiService;
import com.chushouya.product.dto.api.home.DouyinHomeDataDTO;
import com.chushouya.product.service.api.ProductImageApiService;
import com.general.framework.core.schema.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 首页数据接口控制器
 * 提供首页聚合数据查询功能
 * 
 * @author chushouya
 */
@Api(tags = ServiceType.API + "首页接口数据")
@RestController
@RequestMapping(ServiceType.API + "/index")
public class HomeApiController {
    
    @Resource
    private HomeApiService homeApiService;

    @Resource
    private ProductImageApiService productImageApiService;

    @AuthSkip
    @ApiOperation("获取首页聚合数据")
    @GetMapping("/index")
    public Response<HomeDataDTO> homeData(HomeDataQueryDTO homeDataDTO) {
        HomeDataDTO homeData = homeApiService.homeData(homeDataDTO);
        return Response.success(homeData);
    }

    @AuthSkip
    @ApiOperation("获取首页状态")
    @GetMapping("/status")
    public Response statusData() {
        return Response.success();
    }

    @AuthSkip
    @ApiOperation("获取抖音首页数据")
    @GetMapping("/douyin")
    public Response<DouyinHomeDataDTO> douyinHomeData() {
        DouyinHomeDataDTO data = productImageApiService.getDouyinHomeData();
        return Response.success(data);
    }

}
